﻿var page = {

    timer: 0,
    dateTimer: 0,
    /* 此方法在第一次显示窗体前发生 */
    onLoad: function (event) {

    },

    /* 此方法展示窗体后发生 */
    onResume: function (event) {

    },

    /* 当前页状态变化为显示时触发 */
    onShow: function (event) {
        var that = this;
        this.dateTimer = setInterval(function () {
            if (that.num > 0) {
                that.num -= 5;
            }
            console.log(that.num)
        }, 650)

        this.timer = setInterval(function () {
            if (that.num > 120) {
                /*更新下载完成的文本提示，清除定时器*/
                //that.setData({ label1: { value: "Downloading complete !!!" } });
                clearInterval(that.timer);
                clearInterval(that.dateTimer);
                console.log('go to main_page')
                that.setData({ progressbar1: { value: 0 } });
                that.num = 0;
                pm.navigateTo('main_page/main_page');
            } else {
                /*更新progressbar的进度和label的显示文本*/
                that.setData({ progressbar1: { value: that.num } });
            }
        }, 10)
    },

    /* 当前页状态变化为隐藏时触发 */
    onHide: function (event) {

    },

    /* 此方法关闭窗体前发生 */
    onExit: function (event) {
        if (this.dateTimer != 0) {
            clearInterval(this.dateTimer);
        }

        if (this.timer != 0) {
            clearInterval(this.timer);
        }
    },

    num: 0,
    login_btnclick: function (event) {
        this.num += 15;
        console.log(this.num);
    },

};

Page(page);

page = 0;
